﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace DAL
{
    /// <summary>
    ///  小区状况勘察
    /// </summary>
    public class VillageDal : BaseDal<Model.EAVillage>
    {
        public override string tablename
        {
            get { return "EAVillage"; }
        }

        public override Dictionary<string, bool> PKName
        {
            get
            {

                Dictionary<string, bool> dic = new Dictionary<string, bool>();
                dic.Add("village_Id", true);
                return dic;
            }
        }
        /// <summary>
        /// 小区勘察反填
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        public List<EAVillage> GetListByPro(string pro)
        {
            string sql = "select * from EAVillage where ProjectNumber='" + pro + "' ";
            return DBHelper.ExecuteObjects<EAVillage>(sql);
        }
        /// <summary>
        /// 判断项目号是否唯一
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        public int GetCount(string pro)
        {
            string sql = "select count(*) from EAVillage where ProjectNumber='" + pro + "' ";
            return (int)DBHelper.ExecuteScalar(sql);
        }
        /// <summary>
        /// 根据项目编号修改
        /// </summary>
        /// <param name="t"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Update(EAVillage vill)
        {
            string sql = "UPDATE [House].[dbo].[EAVillage] SET [Village_CaseName] = '"+vill.village_CaseName+"',[Village_Cause] = '"+vill.village_Cause+"',[Village_Close] ='"+vill.village_Close+"',[Village_Structure] = '"+vill.village_Structure+"',[Village_Traffic] = '"+vill.village_Traffic+"',[Village_Green] = '"+vill.village_Green+"',[Village_Volume] = '"+vill.village_Volume+"',[Village_Parking] = '"+vill.village_Parking+"',[Village_Property] ='"+vill.village_Property+"',[Village_Explain] = '"+vill.village_Explain+"' WHERE ProjectNumber='"+vill.projectNumber+"'";
            return DBHelper.ExecuteNonQuery(sql)>0;
        }
    }
}
